const Router = require('koa-router');
const path = require('path');
const X = path.basename(module.filename, '.js');
const {splitByLastSeparator} = require('../../../core/util');
const prefix = splitByLastSeparator(path.dirname(__filename), path.sep)[1];
const XModel = require('../../model')[X];
const XValidator = require('../../validator')[X];
const registerCRUDRoute = require('../../../core/registerCRUDRoute');

const router = new Router({
  prefix: `/api/${prefix}/${X.toLowerCase()}`
});

registerCRUDRoute({XValidator, XModel, router});

module.exports = router;
